package protect19;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Circle n1=new Circle("红色","圆形",3.4);
        Rectangle n2=new Rectangle("蓝色","长方形",3.2,4.5);
        System.out.println("矩形的颜色是："+n2.getColor()+",面积是："+n2.findArea());
        System.out.println("圆形的颜色是："+n1.getColor()+",面积是："+n1.findArea());
    }
}
abstract class GeometricObject
{
    private String color;
    private String name;

    public String getColor() {
        return color;
    }

    public String getName() {
        return name;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public void setName(String name) {
        this.name = name;
    }

    public GeometricObject() {
    }

    public GeometricObject(String color, String name) {
        this.color = color;
        this.name = name;
    }
    abstract public double findArea();
}
class Circle extends GeometricObject
{
    private double radius;//半径

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    public Circle(String color, String name, double radius) {
        super(color, name);
        this.radius = radius;
    }

    @Override
    public double findArea() {
        double key;
        key=Math.PI*radius*radius;
        return key;
    }
}
class Rectangle extends GeometricObject
{
    private double width;//宽
    private double height;//高

    public double getWidth() {
        return width;
    }

    public double getHeight() {
        return height;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public Rectangle(String color, String name, double width, double height) {
        super(color, name);
        this.width = width;
        this.height = height;
    }

    @Override
    public double findArea() {
        double key;
        key=width*height;
        return key;
    }
}
